﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OnlineShop
{
    public class Stock
    {
        public IDictionary<Product, int> stockList;

        //Constructor
        public Stock()
        {
           this.stockList = new Dictionary<Product,int>();
        }

        public void AddProductToStock(Product product, int quantity)
        {
            if (product==null)
            {
                throw new ArgumentNullException("Null product cannot be added to stock!");
            }
            if (quantity<=0)
            {
                throw new ArgumentOutOfRangeException
                    ("Quantity of product which is added to stock must be positive integer!");
            }
            stockList.Add(product, quantity);
        }

        public string TakeStock()
        {
            StringBuilder result = new StringBuilder();
            result.AppendFormat("{0}", DateTime.Now);
            foreach (var item in stockList)
            {
                result.AppendFormat("\nType: {0}, Name {1}, Items: {2}",
                    item.Key.productType, item.Key.Name, item.Value);
            }
            return result.ToString();
        }
    }
}
